<%@ page language="java"  pageEncoding="utf-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>

	<div class="search_c_box">
		<a href="###" class="def_btn_s2 fr mr30" id="c_user_link">创建用户</a>
		<div class="search_c">
			<input type="text" class="txt" id="search_key" value="<s:property value="search"/>"/>
			<input type="button" class="btn" value=" " onclick="searchUser();"/>
		</div>
	</div>
	<div class="det_info_box">
		<ul class="c_det_info" id="user_det">
			<s:iterator id="message" value="pageModel.list" status="status">
				<li memberId="<s:property value="id"/>">
					<div class=" c_det_box">
						<div class="c_rel_info">
							<p style="margin-bottom: 5px;"><span><s:property value="id"/></span>&nbsp;&nbsp;&nbsp;<span class="c_name" memberId="<s:property value="id"/>"><s:property value="username"/></span><span><s:property value="schoolName"/></span></p>
                            <p style="margin-bottom: 5px;"><span class="c_phone" style="margin-right:40px;">手机：<s:property value="mobile"/></span><span class="c_mail">电子邮件：<s:property value="email"/></span></p>
                            <p><s:property value="pathName"/></p>
						</div>
						<div class="c_rel_ope">
							<a href="javascript:void(0)" class=" mr15 psd_update" memberId="<s:property value="id" />">密码重设</a><a href="javascript:void(0)" class="mr15 move_out_user" memberId="<s:property value="id" />">移除用户</a><a href="javascript:void(0)"
								class="del_user" memberId="<s:property value="id" />">删除用户</a>
						</div>
					</div>
				</li>
			</s:iterator>


		</ul>

		<!-- fenye -->
		<div class="c_ope_box">
			<div id="fy_container" class="contact_fy fr"></div>
			<div class=" else_ope">
				<a href="javascript:void(0)" id="move_group_link">移动到</a><a href="javascript:void(0)"
					id="user_select_all">全选</a>
			</div>
			<div class="clear"></div>
		</div>
		<!-- fenye--end-->

	</div>

<script type="text/javascript">
	$(function(){
			$.defUnit.pager({
				curPage:<s:property value="pageModel.currentPage" />,
				totalPage:<s:property value="pageModel.totalPage"/>,
				customStyle:"contact_fy",
				containerID:"fy_container",
				afterClickPage:function(page){
					var search_key = $("#search_key").val();
					$("#user_list").load("member!loadUser.do",{
						search:search_key,
						searchRole:editRoleId,
						page:page
					});
				}	
			});
			var isBindAdd = true;
			$("#c_user_link").click(function(){
				$.defUnit.popDiv({
					tcID:"create_user", 
					zzBox:"zz_box",
					isZZ:true	
				});	
				if(isBindAdd){
					$.defUnit.treeMenu({
						treeID:"com_contact_tree"	
					});
					isBindAdd=false;
				}
				
				$.defUnit.downTreeFunc();
			});
			
			var isBind=true;
			$("#move_group_link").bind("click",function(){
				if(isBind){
					$.defUnit.treeMenu({
						treeID:"move_contact_tree"	
					});
					isBind=false;
				}
				
				$.defUnit.moveGroup({
					callback:function(){
						var oUser=$("#user_det").find("li.current");
						if(oUser.length<1){
							alert("没有选择任何数据！");	
						}else{
							$.each(oUser,function(index,obj){
								var roleId = $("#m_new_group_name").attr("roleId");
								$.post("member!moveMember.do",{
									"member.id" : $(obj).find("span.c_name").attr("memberId"),
									"member.roleId" : roleId,
									"oldRoleId":editRoleId
								},function(data){
									var ret = $.parseJSON(data);
									if(ret.success != 'true'){
										alert(ret.msg);
									}
								});
							});	
							$("#m_contact").hide();
							$("div.zz_box").hide();
							alert("移动完毕");
							searchUser();
						}
					}	
				});	
			});
			
			$("a.psd_update").bind("click",function(event){
				$.defUnit.popDiv({
					tcID:"psd_update", 
					zzBox:"zz_box",
					isZZ:true	
				});
				$("#btn_psd").attr("memberId",$(this).attr("memberId"));
				event.stopPropagation();	
			});
			
			var oUserLi=$("#user_det").find("li");
			oUserLi.bind("click",function(){
				if($(this).hasClass("current")){
					$(this).removeClass("current");	
				}else{
					$(this).addClass("current");	
				}	
			});
			
			$("#user_select_all").bind("click",function(){
				oUserLi=$("#user_det").find("li");
				oUserLi.addClass("current");	
			});
			
			$("a.del_user").bind("click",function(event){
				var memberId = $(this).attr("memberId");
				if(confirm("你确定要删除吗？")){
					$.post("member!deleteUser.do",{
						"id":memberId
					},function(data){
						var ret = $.parseJSON(data);
						if(ret.success=='true'){
							searchUser();
						}else{
							alert(ret.msg);
						}
					})
				}
				event.stopPropagation();	
			});
			
			
			$(".move_out_user").click(function(){
				if(confirm("你确定要移除用户吗？")){
					var memberId = $(this).attr("memberId");
					$.post("member!moveOutMember.do",{
						"id":memberId,
						"roleId":editRoleId
					},function(data){
						var ret = $.parseJSON(data);
						if(ret.success == 'true'){
							alert(ret.msg);
							searchUser();
						}else{
							alert(ret.msg);
						}
						
					})
				}
			});	
			
			$("#user_det").find("li").dblclick(function(){
				var memberId = $(this).attr("memberId");
				$("#edit_user").load("member!editUser.do?id="+memberId,function(){
					$.defUnit.popDiv({
						tcID:"edit_user", 
						zzBox:"zz_box",
						isZZ:true	
					});
				});
				
			});
			/*
			$.defUnit.downTreeFunc.Defaults={
				downArrowID:"com_down_arrow",
				comTreeID:"com_contact_tree",
				btnID:"com_btn_sure",
				isBind:true,
				callback:function(){}	
			}
			*/
		});
</script>